import React, { Component } from 'react';
import Child2 from './child2';
import Child3 from './child3';
class child1 extends Component {
    state = { 
      name:'admin',
      age:'66',
      type:'类型',
      username:{
        name:'李四',
        age:'18'
      }
    } 
    // 向子组件传输函数方法 让子组件可以操控父组件的数据
    parent=(val)=>{
      this.setState({
        age:val
      })
      console.log(1);
    }
    render() { 
        return (  
          <>
          <Child2 type={this.state.type} name={this.state.name} username={this.state.username}/>
          <Child3 ageChange={this.parent}/>
          <p>{this.state.age}</p>
          </>
        );
    }
}
 
export default child1;